package Singleton.singleton;

import Singleton.interfaces.Singleton;

/**
 * 通过jvm运行类的时候实例化对象
 * 饿汉模式
 * 这个也是线程安全的
 *
 * @Author: pengzx
 * @Description:
 * @Date: 17:16 2017/9/11
 * @Modified by: 1.0
 */
public class EagerlySingleton extends Singleton {
    private static EagerlySingleton eagerlySingleton = new EagerlySingleton();

    private EagerlySingleton()
    {
        say = "你好...饿汉模式！";
    }

    public static EagerlySingleton getInstance()
    {
        return eagerlySingleton;
    }

    public void say(){
        System.out.println(say);
    }
}
